#!/bin/bash
#Get the date startday
createDay=`echo $1`

#需修改为UAT mongo
BusinessDBName="dfdatadb"
AdminDBUserLogin="/app/MongoDataBase3.0.14/bin/mongo 10.133.78.44:42000/admin  -u admin -p password"
BusinessDBUserLogin="/app/MongoDataBase3.0.14/bin/mongo 10.133.78.44:42000/${BusinessDBName}  -u dfac -p password"


for i in {0..52}
do
echo $i

$BusinessDBUserLogin <<EOF
use ${BusinessDBName};
db.trip_statistics_$createDay.ensureIndex({"routeSTime": 1, "tid": 1 });
db.trip_statistics_$createDay.ensureIndex({"tid": 1 });
db.trip_statistics_$createDay.ensureIndex({"day": 1});
exit
EOF

$AdminDBUserLogin <<EOF
db.runCommand({shardcollection:"${BusinessDBName}.trip_statistics_"+$createDay,key:{"tid": 1}});
EOF


createDay=`date -d "$createDay +7 days" +%Y%m%d`
done
